﻿<%@ WebHandler Language="C#" Class="SIPO.Web.AjaxHandler.Loaddata.getparameters" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using SIPO.Library.DataAccess.Administration.Catalog;
using SIPO.Library.DomainObject.Administration.Catalog;
using SIPO.Library.Enum;
using SIPO.Web.Support;
using Newtonsoft.Json.Linq;
namespace SIPO.Web.AjaxHandler.Loaddata
{
    public class getparameters : SIPO.Web.BaseHandler
    {
        recParameterRepo paramDal = new recParameterRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);

        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);

            var code = string.IsNullOrEmpty(context.Request.Params["ParameterCode"]) ? string.Empty : context.Request.Params["ParameterCode"];

            object result;
            
            if (!string.IsNullOrEmpty(code))           
                result = paramDal.GetById(code.ToLower());
            else
                result = paramDal.GetList();
            
            context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result));
        }

        public override bool IsReusable
        {
            get
            {
                return false;
            }
        }

    }
}